
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Complex {

    private double real;
    private String vir;
    @SuppressWarnings("static-access")
    public static void main(String[] args) throws FileNotFoundException,
            IOException, ClassNotFoundException {
        Complex c1=new Complex(4,"+5i");
        c1.save("complex.txt");
        System.out.println((c1.load("complex.txt")).getComplex());

    }

    public Complex() {
    }
    public Complex(double real,String vir) {
        this.real=real;
        this.vir=vir;
    }

    public String getComplex() {
        return real+vir;
    }
    void save(String filename) throws IOException {
        DataOutputStream output=new DataOutputStream(new FileOutputStream(filename));
        output.writeDouble(real);
        output.writeUTF(vir);
    }
    static Complex load(String fileName) throws ClassNotFoundException, IOException {
        DataInputStream input=new DataInputStream(new FileInputStream(fileName));
        double n=input.readDouble();
        String s=input.readUTF();
        Complex c=new Complex(n,s);
        return c;
    }
}

